<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="utf-8" />
    <title>Max Subtitle Config</title>
</head>

<body>
    <div id="MaxSubtitleProviderConfigPage" data-role="page" class="page type-interior pluginConfigurationPage"
        data-require="emby-input,emby-button,emby-select,emby-checkbox">
        <div data-role="content">
            <div class="content-primary">
                <form id="MaxSubtitleProviderConfigForm">
                    <div class="inputContainer">
                        <label class="inputeLabel inputLabelUnfocused" for="ApiBaseUri">Api</label>
                        <input id="ApiBaseUri" name="ApiBaseUri" type="text" is="emby-input" />
                        <div class="fieldDescription">The API prefix URI, for example: http://192.168.1.11:3000</div>
                    </div>
                    <div>
                        <button is="emby-button" type="submit" class="raised button-submit block emby-button">
                            <span>Save</span>
                        </button>
                    </div>
                </form>
            </div>
        </div>
        <script type="text/javascript">
            var MaxSubtitleProviderConfig = {
                pluginUniqueId: '4EAEDA51-B4CF-45F8-99B3-EB2B1F6D3A53'
            };

            $('#MaxSubtitleProviderConfigPage').on('pageshow', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(MaxSubtitleProviderConfig.pluginUniqueId).then(function (config) {
                    $('#ApiBaseUri').val(config.ApiBaseUri).change();
                    Dashboard.hideLoadingMsg();
                });
            });

            $('#MaxSubtitleProviderConfigForm').on('submit', function () {
                Dashboard.showLoadingMsg();
                ApiClient.getPluginConfiguration(MaxSubtitleProviderConfig.pluginUniqueId).then(function (config) {
                    config.ApiBaseUri = $('#ApiBaseUri').val();
                    ApiClient.updatePluginConfiguration(MaxSubtitleProviderConfig.pluginUniqueId, config).then(function (result) {
                        Dashboard.processPluginConfigurationUpdateResult(result);
                    });
                });
                return false;
            });
        </script>
    </div>
</body>

</html>